<?php
function createTruageRegisterStatusBar(){
	global $connectionstring;
	// TODO: date below should be query from db
	$numOfDay = 7;
	$limitRegisterEachDay = getFieldFromTable("dieukien", "dktoidangay", $connectionstring);
	$currDate = date("Y-m-d");

	print("<table width=\"100%\" border=\"1\" cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"#4693B8\" class=\"normal\">\n");
	print ("<tr>");
	for ($i = 1; $i<=$numOfDay ;$i++) {
		$nextDate = date('Y-m-d', strtotime($currDate .' +'.$i.' day'));
		$nextDayText = date('D', strtotime($currDate .' +'.$i.' day'));
		$nextDayNum = date('N', strtotime($currDate .' +'.$i.' day')) + 1;

		$condition = array("ngaydo" => $nextDate);
		$numOfReg = getTableResultCount("luotdo", $condition, $connectionstring);

		$content = "";
		print("<td align='center' nowrap><b>");
		if ($nextDayText != "Sun") {
			$content .= "<h2>Thứ ". $nextDayNum ."</h2>";
			$content .= " Ngày: ".formatDate($nextDate, 'd-m-Y')."<br/>";
			if ($nextDayText == "Thu") {
				$content .= "Thời gian: 13:30 - 16:30 <br/>";
			}else {
				$content .= "Thời gian: 09:00 - 11:00 <br/>";
			}
			$content .= "<h1 style='color:white;font-size=80px'>".$numOfReg."/".$limitRegisterEachDay."</h1>";
		} else {
			$content .= "<h2>Chủ Nhật</h2>";
			$content .= "Ngày: ".formatDate($nextDate, 'd-m-Y')."<br/>";
			$content .= "Không có Lịch đo<br/><br/><br/><br/><br/>";
		}
		print $content;
		print("</b></td>\n");

	}
	print ("</tr>");
	print ("</table>");
}
?>